import pandas as pd

from src.backend.mydecorator import bean

# @bean('kw')
class KeyWord:
    def __init__(self,path):
        self.word_df=pd.read_excel(path, engine='openpyxl')
        self.keyword=self.get_keyword()

    def get_keyword(self)->[]:
        return self.word_df['three'].values.tolist()

    def get_two_level(self)->[]:
        return self.word_df['two'].values.tolist()
    # def get_keyword(self,data):
    #     labels = []
    #     if isinstance(data, list):
    #         for d in data:
    #             if isinstance(d, str):
    #                 labels.append(d)
    #             else:
    #                 labels.extend(self.get_keyword(d))
    #     else:
    #         for k, d in data.items():
    #             labels.extend(self.get_keyword(d))
    #     return labels
    # def get_labels_at_level(self,data, target_level, current_level=1):
    #     labels = []
    #     if target_level == current_level:
    #         for d in data:
    #             if isinstance(d, dict):
    #                 labels.extend(d.keys())
    #             else:
    #                 labels.append(d)
    #     else:
    #         for key, value in data.items():
    #             # 如果值是字典且当前层级小于目标层级，递归处理
    #             labels.extend(self.get_labels_at_level(value, target_level, current_level + 1))
    #     return labels
